﻿
// lazy load images
jQuery.fn.loadthumb = function(options) {
	options = $.extend({
		 src : ""
	},options);
	var _self = this;
	_self.hide();
	var img = new Image();
	$(img).load(function(){
		_self.attr("src", options.src);
		_self.fadeIn("slow");
	}).attr("src", options.src);
	return _self;
}

$(document).ready(function(){
	function readyImg()
	{
		var len  = $("#picnum").find('span').length;
		//alert(len);
		var index = 0;
		var adTimer;
		$("#picnum span").mouseover(function(){
		index  =   $("#picnum span").index(this);
		showImg(index);
		}).eq(0).mouseover();	
		$('#bigpic').hover(function(){
			 clearInterval(adTimer);
		 },function(){
			 adTimer = setInterval(function(){
				index++;
				if(index==len){index=0;}
				showImg(index);				
			  } , 5000);
		}).trigger("mouseleave");
	}
	var catchImgs=new Array();
	function showImg(index)
	{
		var flagImg=false;
		for(var k=0;k<catchImgs.length;k++)
		{
		   if(catchImgs[k]==index)
		   {
			  flagImg= true;
			  break;
		   }
		}
		if(!flagImg)
		{
			$("#bigpic").addClass("adloading");
			$(".class_img").hide();
			$("#id_img_"+index).loadthumb({src:  src[index] });
			catchImgs.push(index)
		}
		else
		{
			$("#bigpic").removeClass("adloading");
			$(".class_img").hide();
			$("#id_img_"+index).fadeIn("slow");
		}
		
		$("#picnum span").removeClass("on").eq(index).addClass("on");
		$("#id_showImage").attr("href",_href[index]).attr("name","flashAd"+index);
	}	
	
	readyImg();
	

	
});

/*
*酒店选项卡  
*/
$(function(){
	$('div.fList_dt:gt(0)').hide();
	
	var list_m = $('.nav_main ul li');
	
	$('.nav_main ul li').click(function(){
		$(this).addClass('nav_current')
			   .siblings().removeClass('nav_current');
		
		var index = list_m.index(this);
		$('div.fList_dt').eq(index).show()
							 .siblings().hide();
		
		return false;
	});
	
	
});
